/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.citi.dahg.cve.controller.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

/**
 *
 * @author dh90940
 */
@Entity
public class Recurso implements Serializable, CatalogEntity {
    
    @Id
    @Column(name ="soeid")    
    private String soeid;
    private String nombre;
    private String apellido;
    
    @ManyToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "fk_area")
    private Area area;
    
    @Column(name = "es_supervisor")
    private Boolean isSupervisor;
    
    @Column(name = "fecha_ingreso")
    @Temporal(TemporalType.DATE)
    private Date fechaIngreso;
    
    private Integer acumulado;
    
    @ManyToOne(cascade = CascadeType.ALL,optional = true)
    @JoinColumn(name = "fk_supervisor",nullable = true)
    private Recurso supervisor;
    
    @OneToMany(mappedBy="recurso")
    private List<Vacacion> vacaciones;
    
    
    public Recurso() {}
    public Recurso(String soeid,String nombre, String apellido, Area area, Date fechaIngreso) {
        this.soeid = soeid;
        this.nombre = nombre;
        this.apellido = apellido;
        this.area = area;        
        this.fechaIngreso = fechaIngreso;        
    }
    
    @Transient
    public String getNombreCompleto() {
        return nombre+" "+apellido;
    }
    
    @Override
    public String toString() {
        return soeid;
    }
    
    public String getSoeid() {
        return soeid;
    }

    public void setSoeid(String soeid) {
        this.soeid = soeid;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getApellido() {
        return apellido;
    }

    public void setApellido(String apellido) {
        this.apellido = apellido;
    }

    public Area getArea() {
        return area;
    }

    public void setArea(Area area) {
        this.area = area;
    }

    public Boolean isIsSupervisor() {
        return isSupervisor;
    }

    public void setIsSupervisor(Boolean isSupervisor) {
        this.isSupervisor = isSupervisor;
    }

    public Date getFechaIngreso() {
        return fechaIngreso;
    }

    public void setFechaIngreso(Date fechaIngreso) {
        this.fechaIngreso = fechaIngreso;
    }

    public Integer getAcumulado() {
        return acumulado;
    }

    public void setAcumulado(Integer acumulado) {
        this.acumulado = acumulado;
    }

    public Recurso getSupervisor() {
        return supervisor;
    }

    public void setSupervisor(Recurso supervisor) {
        this.supervisor = supervisor;
    }    

    public List<Vacacion> getVacaciones() {
        return vacaciones;
    }

    public void setVacaciones(List<Vacacion> vacaciones) {
        this.vacaciones = vacaciones;
    }
    
    @Override
    public int hashCode() {
        int hash = 7;
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Recurso other = (Recurso) obj;
        if ((this.soeid == null) ? (other.soeid != null) : !this.soeid.equals(other.soeid)) {
            return false;
        }
        return true;
    }

    @Override
    public Object getPrimaryKey() {
        return getSoeid();
    }    
    
}
